home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
tpfast30.zip
/
FASTSTR.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-09-26
|
51KB
|
943 lines
; _______________________________________________________________
; | |
; | Copyright (C) 1989,1990 Steven Lutrov |
; |_______________________________________________________________|____
; | | |
; | Program Title : FastStr.Asm | | ___
; | Author : Steven Lutrov | | |
; | Revision : 2.01 | | |
; | Date : 1990-03-16 | | |
; | Language : Turbo Assembler | | |
; | | | |
; | Description : Assembly Functions For String Manipulation. | | |
; | : Tested on Turbo Pascal 5.0 & 5.5 | | |
; | | | |
; |_______________________________________________________________| | |
; | | |
; |________________________________________________________________| |
; | |
; |_________________________________________________________________|
;
Code Segment Word Public
Assume Cs:Code,Ds:Data
Public Changechar,Compare,Stringend,Deletechar,Deleteleft,Deleteright
Public Leftend,Lowercase,Overwrite,Padcentre,Padends,Padleft,Padright
Public Replace,Rightend,Seekstring,Stringof,Uppercase,Wordcount
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;Procedure Changechar(Var Strx: Stype; Search,Replace: Char);
;
;
Data Segment
Extrn Errreturn:Byte
Data Ends
;
;
Changechar Proc Far
Push Bp ;Save Bp
Mov Bp,Sp ;Set Up Stack Frame
Mov Errreturn,0 ;Assume Char Found
Les Di,Dword Ptr[Bp+10] ;Es:Di Pts To Strx
Sub Dx,Dx ;Flags That A Char Found
Mov Al,[Bp+6] ;Get Replacement Char
Mov Ah,[Bp+8] ;Search Character
Sub Cx,Cx ;Clear Cx
Mov Cl,Es:[Di] ;Get String Length
Jcxz Changechar3 ;Quit If Null String
Changechar1: Inc Di ;Forward String Ptr
Cmp Es:[Di],Ah ;Search Char?
Jne Changechar2 ;Jump Ahead If Not
Mov Es:[Di],Al ;Else Change Char
Inc Dx ;Flag That A Char Found
Changechar2: Loop Changechar1 ;Go Do Next Char
Or Dx,Dx ;Test If Char Found
Jnz Changechar4 ;Jump Ahead If So
Changechar3: Inc Errreturn ;Else 1 = Char Not Found
Changechar4: Pop Bp ;Restore Bp And Quit
Ret 8
Changechar Endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;Function Compare(Strg1,Strg2: Stype): Boolean;
;
;
Compare Proc Far
Mov Bx,Sp ;Bx Pts To Stack
Push Ds ;Save Turbo'S Ds
Les Di,Ss:Dword Ptr[Bx+8] ;Es:Di Pts To Strg1
Lds Si,Ss:Dword Ptr[Bx+4] ;Ds:Si Pts To Strg2
Sub Cx,Cx ;Clear Cx
Mov Cl,[Si] ;Get Strg2 Length
Cmp Cl,Es:[Di] ;Equal To Strg1 Length?
Jne Compare6 ;Quit If Not
Jcxz Compare5 ;Quit If Both Null
Compare1: Inc Di ;Forward Strg1 Ptr
Inc Si ;Forward Strg2 Ptr
Mov Al,[Si] ;Get Strg2 Char
Cmp Al,Es:[Di] ;Compare To Strg1 Char
Je Compare4 ;Loop If Equal
Cmp Al,122 ;Above Lower Case Vals?
Ja Compare6 ;Quit If So
Cmp Al,97 ;Lower Case Char?
Jnae Compare2 ;Jump Ahead If Not
Sub Al,32 ;Make Lower Case
Jmp Short Compare3 ;Go Test It
Compare2: Cmp Al,90 ;Above Upper Case Vals?
Ja Compare6 ;Quit If So
Cmp Al,65 ;Upper Case Char?
Jnae Compare6 ;Quit If Not
Add Al,32 ;Make Lower Case
Compare3: Cmp Al,Es:[Di] ;Compare To Strg1 Char
Jne Compare6 ;Quit If Not Equal
Compare4: Loop Compare1 ;Go Do Next Char
Compare5: Mov Al,1 ;Return True
Jmp Short Compare7 ;Jump Ahead
Compare6: Mov Al,0 ;Return False
Compare7: Pop Ds ;Restore Ds And Quit
Ret 8
Compare Endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;Function Stringend(Strx: Stype; Numberchars: Integer): Stype;
;
;
Data Segment
Extrn Errreturn:Byte
Data Ends
;
;
Stringend Proc Far
Push Bp ;Save Bp
Mov Bp,Sp ;Set Up Stack Frame
Push Ds ;Save Ds
Les Di,Dword Ptr[Bp+12] ;Es:Di Pts To Return Strx
Lds Si,Dword Ptr[Bp+8] ;Ds:Si Pts To Source Strx
Sub Cx,Cx ;Clear Cx
Mov Es:[Di],Cl ;Return Null String If Error
Mov Cl,[Bp+6] ;Get Numberchars (255 Max)
Sub Bx,Bx ;Clear Bx
Mov Bl,[Si] ;Strx Length In Bx
Mov Dl,1 ;1 = Null String
Or Bl,Bl ;Test For Null String
Jz Stringend3 ;Quit Routine If Null
Dec Dl ;0 = No Error
Cmp Cx,Bx ;Numberchars < Length?
Jbe Stringend1 ;Jump Ahead If So
Mov Cx,Bx ;Else Return Whole String
Mov Dl,2 ;2 = Numberchars Greater Than Length
Stringend1: Mov Es:[Di],Cl ;Return Strx Descriptor
Sub Bx,Cx ;Length Minus Numberchars
Inc Di ;Forward Return Strx Ptr To First Char
Inc Si ;Save For Source Strx
Add Si,Bx ;Add Starting Offset To Source
Stringend2: Cld ;Direction Forward
Rep Movsb ;Move The Portion Of The String
Stringend3: Pop Ds ;Restore Ds
Mov Errreturn,Dl ;Set Errreturn
Pop Bp ;Restore Bp And Quit
Ret 6
Stringend Endp
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;Procedure Deletechar(Var Strx: Stype; Ch: Char);
;
;
Data Segment
Extrn Errreturn:Byte
Data Ends
;
;
;
Dele